using UnityEngine;
using System.Collections;

public class SpudGunBullet : MonoBehaviour {
	public float scaler = 10;
	private float scale = 0;
	private float explosionForce = 1000;
	// Use this for initialization
	void Start () {
		this.renderer.enabled = false;
		//Physics.IgnoreCollision(rigidbody.collider,transform.collider,true);
		
	}
	
	// Update is called once per frame
	void Update () {
		this.GetComponent<SphereCollider>().radius += scaler*Time.deltaTime;
		
		Destroy(this.gameObject,1);
		//scale += Time.deltaTime*scaler;
		//this.rigidbody.AddForce
		
	}
	void OnDrawGizmos() {
		Gizmos.DrawWireSphere(this.collider.bounds.center,this.GetComponent<SphereCollider>().radius/2);		
	}
	
	 void OnTriggerEnter(Collider other) {
		Debug.Log("COLLISION!");
		//if (collision.
        // Debug-draw all contact points and normals
       // for (var contact : ContactPoint in collision.contacts)
       //     Debug.DrawRay(contact.point, contact.normal, Color.white);
        
        // Play a sound if the coliding objects had a big impact.        
       // if (collision.relativeVelocity.magnitude > 2)
       //     audio.Play();
		//foreach (ContactPoint contact in collision.contacts) {
			
				
			//.AddExplosionForce(explosionForce,this.transform.position,this.GetComponent<SphereCollider>().radius);
				//if (other.gameObject.GetComponent<RigidbodyFPSController>() != null) {
		if (other.gameObject.GetComponent<Rigidbody>() != null) {
			Debug.Log("RIGIDBODY COLLISION!");
					other.rigidbody.AddForce(this.rigidbody.velocity*10);//+new Vector3(0,1000,0));//,ForceMode.Impulse);
					//other.rigidbody.AddExplosionForce(explosionForce,this.transform.position,this.GetComponent<SphereCollider>().radius);
				}
				
					
		//	}
		//}
    }
}

